package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysProjectFundingSource;
import com.ruoyi.system.service.ISysProjectFundingSourceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 资金来源Controller
 * 
 * @author ruoyi
 * @date 2024-08-03
 */
@RestController
@RequestMapping("/system/projectfundingsource")
public class SysProjectFundingSourceController extends BaseController
{
    @Autowired
    private ISysProjectFundingSourceService sysProjectFundingSourceService;

    /**
     * 查询资金来源列表
     */
    @PreAuthorize("@ss.hasPermi('system:projectfundingsource:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysProjectFundingSource sysProjectFundingSource)
    {
        startPage();
        List<SysProjectFundingSource> list = sysProjectFundingSourceService.selectSysProjectFundingSourceList(sysProjectFundingSource);
        return getDataTable(list);
    }

    /**
     * 查询资金来源列表
     */
    @PreAuthorize("@ss.hasPermi('system:projectfundingsource:lists')")
    @GetMapping("/lists")
    public AjaxResult lists(SysProjectFundingSource sysProjectFundingSource)
    {
        List<SysProjectFundingSource> list = sysProjectFundingSourceService.selectSysProjectFundingSourceList(sysProjectFundingSource);
        return success(list);
    }

    /**
     * 导出资金来源列表
     */
    @PreAuthorize("@ss.hasPermi('system:projectfundingsource:export')")
    @Log(title = "资金来源", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysProjectFundingSource sysProjectFundingSource)
    {
        List<SysProjectFundingSource> list = sysProjectFundingSourceService.selectSysProjectFundingSourceList(sysProjectFundingSource);
        ExcelUtil<SysProjectFundingSource> util = new ExcelUtil<SysProjectFundingSource>(SysProjectFundingSource.class);
        util.exportExcel(response, list, "资金来源数据");
    }

    /**
     * 获取资金来源详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:projectfundingsource:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysProjectFundingSourceService.selectSysProjectFundingSourceById(id));
    }

    /**
     * 新增资金来源
     */
    @PreAuthorize("@ss.hasPermi('system:projectfundingsource:add')")
    @Log(title = "资金来源", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysProjectFundingSource sysProjectFundingSource)
    {
        return toAjax(sysProjectFundingSourceService.insertSysProjectFundingSource(sysProjectFundingSource));
    }

    /**
     * 修改资金来源
     */
    @PreAuthorize("@ss.hasPermi('system:projectfundingsource:edit')")
    @Log(title = "资金来源", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysProjectFundingSource sysProjectFundingSource)
    {
        return toAjax(sysProjectFundingSourceService.updateSysProjectFundingSource(sysProjectFundingSource));
    }

    /**
     * 删除资金来源
     */
    @PreAuthorize("@ss.hasPermi('system:projectfundingsource:remove')")
    @Log(title = "资金来源", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysProjectFundingSourceService.deleteSysProjectFundingSourceByIds(ids));
    }
}
